﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace NullSuicide
{
    public partial class AddPlayer : Form
    {
        Delegate m_addfunction;
        Control m_parent;

        public AddPlayer(Delegate addfunction, Control parent)
        {
            m_addfunction = addfunction;
            InitializeComponent();
            m_parent = parent;
        }

        private void Add_Click(object sender, EventArgs e)
        {
            if (this.Name != string.Empty)
            {
                // string name, int possition, bool inRaid

                object[] properties = new object[3];
                properties[0] = this.tbNameplayer.Text;

                if (this.tbPossition.Text == string.Empty)
                {
                    properties[1] = -1;
                }
                else
                {
                    properties[1] = Convert.ToInt32(this.tbPossition.Text);
                }

                properties[2] = this.cbInRaid.Checked;

                m_addfunction.Method.Invoke(m_parent, properties);

                this.Close();
            }
        }

        private void Cancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
